package pl.makimo.fuzzy.linguistics;

import java.util.List;

import pl.makimo.fuzzy.norms.MinNorm;
import pl.makimo.fuzzy.norms.Norm;
import pl.makimo.fuzzy.norms.Type2Norm;
import pl.makimo.fuzzy.sets.CrispSet;

public class Summary<T> {
	public Quantifier quantifier;
	public Qualifier<T> qualifier;
	public Summarizer<T> summarizer;
	
	public CrispSet<T> tuples;
	
	public Norm type1norm = new MinNorm();
	public Norm type2norm = new Type2Norm();
	
	public Summary(Quantifier quantifier, Qualifier<T> qualifier,
			Summarizer<T> summarizer, CrispSet<T> tuples, Norm type1norm, Norm type2norm) throws Exception {
		super();
		
		this.tuples = tuples;
		
		this.quantifier = quantifier;
		this.qualifier = qualifier;
		this.summarizer = summarizer;
		
		if (!this.quantifier.relative) {
			this.qualifier = null;
			throw new Exception("Cannot use absolute quantifiers with qualified expressions.");
		}		
	}

	public Summary(Quantifier quantifier, Summarizer<T> summarizer, CrispSet<T> tuples, Norm type1norm, Norm type2norm) {
		super();
		
		this.quantifier = quantifier;
		this.summarizer = summarizer;
		this.tuples = tuples;
	}

	public List<Summarizer<T>> getSingleSummarizers() {
		return this.summarizer.getSingleSummarizers();
	}	
	
	public List<Qualifier<T>> getSingleQualifiers() {
		return this.qualifier.getSingleQualifiers();
	}		
	
	@Override
	public String toString() {
		if (this.qualifier == null) {
			return quantifier.toString() + " records are/have " + summarizer.toString();
		} else {
			return quantifier.toString() + " records that are/have " + qualifier.toString() + " are/have " + summarizer.toString();
		}
	}
}
